import http from './public'
const baseUrl = process.env.API_BASEURL;

//登录接口
export const login = (params) => {
		if(params && params.url){
		return http.fetchPost(`${baseUrl}`+params.url, params)
	}
	return http.fetchPost(`${baseUrl}/wap/index.php?ctl=user&act=do_register`, params)
}

// 修改密码
export const changePassword = (params) => {
	return http.fetchPost(`${baseUrl}/wap/index.php?ctl=user&act=do_getPassword`, params)
}

// 实名认证接口
export const idAuth = (params) => {
	return http.fetchPost(`${baseUrl}/wap/index.php?ctl=settings&act=verify_id`, params)
}

// 修改昵称
export const changeNickName = (params) => {
	return http.fetchPost(`${baseUrl}/wap/index.php?ctl=settings&act=nicename_modify`, params)
}

// 获取首页列表
export const getIndexList = (params) => {
	if(params.url){
		return http.fetchPost(`${baseUrl}`+params.url, params)
	}
	return http.fetchPost(`${baseUrl}/wap/index.php?ctl=index&tpl=1`, params)
}

// 获取分类列表
export const getCateList = (params) => {
	if(params && params.url){
		return http.fetchPost(`${baseUrl}`+params.url, params)
	}
	return http.fetchPost(`${baseUrl}/wap/index.php?ctl=deals&tpl=1&param=1`, params)
}

// 发送短信验证码
export const getCode = (params) => {
	return http.fetchPost(`${baseUrl}/wap/index.php?ctl=user&act=verfiy&mobile=`+params.mobile)
}

// 获取产品详情
export const getPJDetail = (params) => {
	return http.fetchPost(`${baseUrl}/wap/index.php?ctl=deal&act=show&tpl=1&id=`+params.id)
}

// 获取项目发起团队
export const getTeamApi = (params) => {
	return http.fetchPost(`${baseUrl}/wap/index.php?ctl=deal&act=show&tpl=1&team=1&id=`+params.id)
}

// 获取发现页列表
export const getGuide = () => {
	return http.fetchPost(`${baseUrl}/wap/index.php?ctl=deals&act=index&tpl=1&type=0&xiaofei=1&deal_ctype=3`)
}

// 获取往期合集列表
export const getPassed = (params) => {
	if(params && params.url){
		return http.fetchPost(`${baseUrl}`+params.url, params)
	}
	return http.fetchPost(`${baseUrl}/wap/index.php?ctl=deals&act=index&tpl=1&passed=1`)
}

// 获取文章列表
export const getArticleList = () => {
	return http.fetchPost(`${baseUrl}/wap/index.php?ctl=article_cate&tpl=1&id=39`)
}

// 获取文章详情
export const getArticleDetail = (params) => {
	return http.fetchPost(`${baseUrl}/wap/index.php?ctl=article&tpl=1&id=`+params.id)
}

// 发送项目发起表
export const postSponsor = (params) => {
	return http.fetchPost(`${baseUrl}/wap/index.php?ctl=project&act=save`,params)
}
